home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1998 July
/
EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso
/
recent
/
grabur.lha
/
graburl
/
regexp.txt
< prev
Wrap
Text File
|
1998-01-05
|
2KB
|
54 lines
This is a part of the output from "man regexp" on my computer.
Not extremely clear the first time you read it, but should be enough to
start with regular expressions.
I put a couple of examples at the end of this file.
REGULAR EXPRESSION SYNTAX
A regular expression is zero or more branches, separated by |'. It
matches anything that matches one of the branches.
A branch is zero or more pieces, concatenated. It matches a match for
the first, followed by a match for the second, etc.
A piece is an atom possibly followed by `*', `+', or `?'. An atom fol-
lowed by `*' matches a sequence of 0 or more matches of the atom. An
atom followed by `+' matches a sequence of 1 or more matches of the atom.
An atom followed by `?' matches a match of the atom, or the null string.
An atom is a regular expression in parentheses (matching a match for the
regular expression), a range (see below), `.' (matching any single char-
acter), `^' (matching the null string at the beginning of the input
string), `$' (matching the null string at the end of the input string), a
`\' followed by a single character (matching that character), or a single
character with no other significance (matching that character).
A range is a sequence of characters enclosed in `[]'. It normally match-
es any single character from the sequence. If the sequence begins with
`^', it matches any single character not from the rest of the sequence.
If two characters in the sequence are separated by `-', this is shorthand
for the full list of ASCII characters between them (e.g. `[0-9]' matches
any decimal digit). To include a literal `[' in the sequence, make it
the first character (following a possible `^'). To include a literal
`-', make it the first or last character.
A couple of examples
~~~~~~~~~~~~~~~~~~~~
Pattern: dre
Matches: andrew.com
Pattern: jp.*g
Matches: hey.jpg ho.jpyg boo.jpxxxxg
Pattern: jpe+g
Matches: hey.jpeg hey.jpeeg
Dont ma: hey.jpg
Pattern: \.(gif|jpe*g)
Matches: hello.giffe hello.gif banner.jpg banner.jpeg banner.jpeeg
Pattern: \.(gif|jpe*g)$
Matches: hello.gif banner.jpg banner.jpeg
Dont ma: hello.giffe